
<link rel="stylesheet" href="__CSS__/upass.css"/>

<!--修改密码 弹框-->
<div class="upass">
    <form method="post" onsubmit=upass("{$username}") enctype="multipart/form-data">
        <div id="upass">
            <div class="ltitle" style="text-align: center;">修改密码</div>
            <div class="new-del">
                <span class="u-span">用户名</span>
                <input type="text" name="username_upass" value="{$username}" class="fa-input" readonly style="background-color: grey">
            </div>
            <div class="new-del">
                <span class="u-span">原密码</span>
                <input type="password" name="oldpass" class="fa-input">
            </div>
            <div class="new-del">
                <span class="u-span">新密码</span>
                <input type="password" name="newpass" class="fa-input">
            </div>
            <div class="new-del">
                <span class="u-span">新密码确认</span>
                <input type="password" name="confirm" class="fa-input">
            </div>
            <div class="alert-btn" style=" margin-top: 16px;">
                <button type="submit" class="alert-sure" style="margin-left: 30%; border-radius: 5px;">确定</button>
                <span class="alert-cancel" style=" border-radius: 5px;">取消</span>
            </div>
        </div>
    </form>
</div>
<script src="__JS__/jquery.js"></script>
<script>

    function upass() {
        var username = $("input[name='username_upass']").val()
        var password = $("input[name='oldpass']").val()
        var update = $("input[name='newpass']").val()
        var confirm = $("input[name='confirm']").val()
        //console.log(model_id)
        var data = {'username':username,'password':password,'update':update, 'confirm':confirm}
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "{:url('Base/upass')}",//url
            data: data,
            success: function (result) {
                var code = result.code;
                var msg = result.msg;
                changeText(msg, code)
                //成功返回登录界面
                if(code == 1){
                    window.location.href="{:url('Login/index')}"
                }
            },
            error:function (result) {
                alert('服务器错误')

            }
        });
    }
    $(function () {
        $(".alert-close").click(function () {
            $(".upass").css("display","none")
        })
        $(".alert-cancel").click(function () {
            $(".upass").css("display","none")
        })
        $(".class-upass").click(function () {
            $(".upass").css("display","block")
        })

    })

</script>